<?php
include('global.php');				//引入全局主文件
$fenlei = $action->_get_fenlei();	//查询所有分类
if(isset($_GET['typeid']))
{
	$typeid = $_GET['typeid'];
}
else
{
	$typeid = false;
}
$all = $action->_read_count_books();				//图书总数
$typename = $action->_get_type_name($typeid);		//读取当前分类的名称			
$book_in_type = $action->_get_book_in_type($typeid);//读取本类文章
$total  = $book_in_type[1];							//总记录数
$result = $book_in_type[0];							//显示在当前页的图书
pageft($total, DISPLAY, 1, 1, 1, 5);				//执行分页函数
$GLOBALS['pos'] = '<a href="book_by_class.php" target="_self">图书分类</a>' . $typename;
$GLOBALS['title'] = '图书管理系统 - 图书分类';
?>
<?php include('public/top.php');//引入头?>
<div class="left">
  <div class="left1">
    <h1>图书分类</h1>
    <ul>
    <li>
    	<a href="book_by_class.php?typeid=0">所有图书</a>
    	<em>(<?php echo $all;?>)&nbsp;<img src="style/image/arr3.gif" /></em></li>
    <?php
	if(!empty($fenlei))
	{
    	foreach($fenlei as $v)
		{
			echo '<li><a href="book_by_class.php?typeid=' . $v['id'] . '" title="' . $v['description'] . '">' . $v['value'] . '</a>';
			echo '<em>(' . $v['counts'] . ')&nbsp;<img src="style/image/arr3.gif" /></em></li>';
		}
	}
	else
	{
		echo '<li>暂无分类</li>';
	}
	?>
    </ul>
 </div>
</div>
<div class="right">
  <div class="rclass">
    <h2>图书列表<?php echo isset($typename) ? $typename : '';?></h2>
    <div class="field4">
	<table>
    	<tr class="field4_title">
            <td width="30%">图书名称</td>
            <td width="15%">作者</td>
            <td width="20%">出版日期</td>
            <td width="20%">出版社</td>
            <td width="15">可借复本（本）</td>
          </tr>
        <?php
		if(!empty($result))
		{
			foreach($result as $v)
			{
		?>
        <tr>
            <td><?php echo '<a href="book_view.php?bookid=' . $v['bid'] . '">' . $v['name'] . '</a>';?></td>
            <td><?php echo $v['author'];?></td>
            <td><?php echo d($v['pdate']);?></td>
            <td><?php echo $v['pstore'];?></td>
            <td><?php echo $v['storage'];?></td>
         </tr>
        <?php
			}
		}
		else
		{
			echo '<td colspan="5">该栏目暂无图书</td>';
		}
		?>
       <tr>
       <td class="pager" colspan="5"><?php echo $pagenav;?></td>
        </tr>
    	</table>
      <div class="clr"></div>
    </div>
  </div>
</div>
<?php echo $copyright;?>
</body>
</html>